#include<iostream>
using namespace std;
const int N=1e6+10;
long long nums[N];
int main()
{
	long long n,m;cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>nums[i];
	int right=4e5;
	int left=0;
	while(left<right)
	{
		int mid=left+(right-left+1)/2;
		long long ret=0;
		for(int i=1;i<=n;i++)
		{
			if(nums[i]>mid)
			{
				ret+=nums[i]-mid;
			}
		}
		if(ret>=m)
		{
			left=mid;
		}
		else
		{
			right=mid-1;
		}
	}
	cout<<left<<endl;
}